package com.bnlr.lrparking.appui.stall;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.MapPoi;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.TextureMapView;
import com.baidu.mapapi.model.LatLng;
import com.blankj.utilcode.util.ToastUtils;
import com.bnlr.lrparking.appui.order.stages.ByStagesDetailsActivity;
import com.bnlr.lrparking.appui.web.CarWebActivity;
import com.bnlr.lrparking.appui.order.stages.SubmitMessageActivity;
import com.bnlr.lrparking.appui.login.VerificaActivity;
import com.bnlr.lrparking.constant.LrConstant;
import com.bnlr.lrparking.constant.Urls;
import com.bumptech.glide.Glide;
import com.jn.chart.charts.LineChart;
import com.jn.chart.data.Entry;
import com.jn.chart.manager.LineChartManager;
import com.jn.chart.manager.LineChartManager1;
import com.bnlr.lrparking.app.Application;
import com.bnlr.lrparking.R;
import com.bnlr.lrparking.adapter.StallDealDetailAdapter;
import com.bnlr.lrparking.base.BaseActivity;
import com.bnlr.lrparking.app.AppConfig;
import com.bnlr.lrparking.model.BaseArrayBean;
import com.bnlr.lrparking.model.StagesBankBean;
import com.bnlr.lrparking.model.StallDetailBean;
import com.bnlr.lrparking.util.CommonUtil;
import com.bnlr.lrparking.util.CustomLinearLayoutManager;
import com.bnlr.lrparking.util.GlideImageLoader;
import com.bnlr.lrparking.view.CarCommon;
import com.bnlr.lrparking.widget.photo.PhotoViewerActivity;
import com.bnlr.lrparking.widget.photo.PhotoViewerBean;
import com.bnlr.nohttp.CallServer;
import com.bnlr.nohttp.CustomHttpListener;
import com.yolanda.nohttp.NoHttp;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.listener.OnBannerListener;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import jp.wasabeef.glide.transformations.CropCircleTransformation;

/**
 * 车位交易详情
 *
 * @author hp
 * @date 2017/9/15
 */
public class StallDealDetailActivity extends BaseActivity {

    @BindView(R.id.rely_stalldeal_phone)
    RelativeLayout rely_stalldeal_phone;
    @BindView(R.id.rely_stalldeal_coll)
    RelativeLayout rely_stalldeal_coll;
    @BindView(R.id.deal_detail_title)
    TextView title;
    @BindView(R.id.stall_map)
    TextureMapView stall_map;
    @BindView(R.id.map_frameLayout)
    FrameLayout frameLayout;
    @BindView(R.id.deal_detail_date)
    TextView date;
    @BindView(R.id.deal_detail_price)
    TextView price;
    @BindView(R.id.deal_detail_area)
    TextView area;
    @BindView(R.id.deal_detail_size)
    TextView size;
    @BindView(R.id.tv_equities)
    TextView tv_equities;
    @BindView(R.id.deal_detail_type)
    TextView type;
    @BindView(R.id.tv_floor)
    TextView tv_floor;
    @BindView(R.id.tv_stalltype)
    TextView tv_stalltype;
    @BindView(R.id.tv_plotname)
    TextView tv_plotname;
    @BindView(R.id.tv_location_advantage)
    TextView tv_location_advantage;
    @BindView(R.id.deal_detail_address)
    TextView address;
    @BindView(R.id.checkBox_college)
    CheckedTextView checkBox_college;
    @BindView(R.id.image_stalldealdetail)
    Banner imageStalldealdetail;
    @BindView(R.id.image_datum)
    ImageView image_datum;
    @BindView(R.id.rely_stalldeal_anim)
    RelativeLayout rely_stalldeal_anim;
    @BindView(R.id.iwant_buy)
    TextView iwant_buy;
    @BindView(R.id.stalldealdetail_back)
    ImageView stalldealdetail_back;
    @BindView(R.id.deal_detail_stallnum)
    TextView deal_detail_stallnum;
    private Unbinder unbinder;
    @BindView(R.id.imageView57)
    ImageView ivAuth;
    @BindView(R.id.textView11)
    TextView tvAuthStatus;
    @BindView(R.id.desc)
    TextView desc;
    @BindView(R.id.imageView55)
    ImageView ivHead;
    @BindView(R.id.deal_detail_name)
    TextView name;
    @BindView(R.id.textView23)
    TextView registerDate;
    @BindView(R.id.textView24)
    TextView messageCount;
    @BindView(R.id.stalldealdetail_type)
    TextView stalldealdetail_type;
    @BindView(R.id.recycler_stalldeal)
    RecyclerView recycler_stalldeal;
    @BindView(R.id.stall_detail_status_int)
    TextView tvStatusInt;
    @BindView(R.id.rely_stalldeal_buy)
    RelativeLayout rlSubmit;
    @BindView(R.id.rely_subscribe)
    RelativeLayout rely_subscribe;
    @BindView(R.id.rely_bystages)
    RelativeLayout rely_bystages;
    @BindView(R.id.iv_blfq)
    ImageView ivBlfq;
    @BindView(R.id.rely_approvemessage)
    RelativeLayout rely_approvemessage;
    @BindView(R.id.tv_fqbl_lc)
    TextView tvFqblLc;
    @BindView(R.id.scroll_stalldetail)
    ScrollView scroll_stalldetail;
    @BindView(R.id.no_data)
    RelativeLayout no_data;
    @BindView(R.id.rely_bottom)
    RelativeLayout rely_bottom;
    @BindView(R.id.lay_xk)
    LinearLayout lay_xk;
    @BindView(R.id.lay_plotprice)
    LinearLayout lay_plotprice;
    @BindView(R.id.lay_stallprice)
    LinearLayout lay_stallprice;
    @BindView(R.id.lineChart)
    LineChart mLineChart;
    @BindView(R.id.lineChart1)
    LineChart mLineChart1;
    @BindView(R.id.image_LocalPhoto)
    Banner image_LocalPhoto;
    @BindView(R.id.tv_number_top)
    TextView tvNumberTop;
    @BindView(R.id.tv_property)
    TextView tvProperty;
    @BindView(R.id.tv_build_time)
    TextView tvBuildTime;
    @BindView(R.id.ll_property)
    LinearLayout llProperty;
    @BindView(R.id.ll_build_time)
    LinearLayout llBuildTime;
    @BindView(R.id.tv_platform_num)
    TextView tvPlatformNum;
    @BindView(R.id.deal_detail_read_count)
    TextView tvReadCount;
    @BindView(R.id.deal_detail_collect_count)
    TextView tvCollectCount;
    private int IsFavorite;
    CarCommon common = new CarCommon();
    private String spaceowertype = "";//0是个人1是开发商
    private List<String> photolist = new ArrayList<>();//
    private List<String> photolist1 = new ArrayList<>();//销控图
    private StallDetailBean.DataBean db;
    private int stallId;
    private StallDetailBean.DataBean.DevelopModelBean developModel;
    private StallDealDetailAdapter stallDealDetailAdapter;
    private List<StallDetailBean.DataBean.DiscountData> dataList = new ArrayList<>();
    private BaiduMap mBaidumap;
    private boolean isWaiting = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_stalldealdetail);
        unbinder = ButterKnife.bind(this);
        stallId = getIntent().getIntExtra("stall_id", 0);
        isWaiting = getIntent().getBooleanExtra("is_waiting", false);
        if (isWaiting) {
            //是否是从我的发布 正在审核中点进来的
            rely_bottom.setVisibility(View.GONE);
        }
        initView();
        imageStalldealdetail.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                if (photolist.size() > 0) {
                    PhotoViewerBean photoViewerBean = new PhotoViewerBean(photolist, position);
                    startActivity(new Intent(StallDealDetailActivity.this,
                            PhotoViewerActivity.class)
                            .putExtra(PhotoViewerActivity.PHOTO_VIEWER_TAG, photoViewerBean));
                }
            }
        });
        image_LocalPhoto.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                if (photolist1.size() > 0) {
                    PhotoViewerBean photoViewerBean = new PhotoViewerBean(photolist1, position);
                    startActivity(new Intent(StallDealDetailActivity.this,
                            PhotoViewerActivity.class)
                            .putExtra(PhotoViewerActivity.PHOTO_VIEWER_TAG, photoViewerBean));
                }
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        stall_map.onResume();
        setParkingdetails(stallId + "");
    }

    @Override
    protected void onPause() {
        super.onPause();
        //在activity执行onPause时执行mMapView. onPause ()，实现地图生命周期管理
        stall_map.onPause();
    }

    private void initView() {
        //setParkingdetails(stallId + "");
        image_datum.setOnClickListener(this);
        rely_stalldeal_phone.setOnClickListener(this);
        rely_stalldeal_coll.setOnClickListener(this);
        rlSubmit.setOnClickListener(this);
        rely_subscribe.setOnClickListener(this);
        stalldealdetail_back.setOnClickListener(this);
        ivBlfq.setOnClickListener(this);
        stall_map.setOnClickListener(this);
        tvFqblLc.setOnClickListener(this);
        CustomLinearLayoutManager linearLayoutManager = new CustomLinearLayoutManager(baseContext);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        linearLayoutManager.setScrollEnabled(false);
        recycler_stalldeal.setLayoutManager(linearLayoutManager);

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            //打电话
            case R.id.rely_stalldeal_phone:
                if (!AppConfig.getInstance().getBoolean("isLogin", false)) {
                    startActivity(new Intent(this, VerificaActivity.class));
                    return;
                }
                if (db != null) {
                    if (AppConfig.getInstance().getString("uid", "").equals(db.getUserId() + "")) {
                        ToastUtils.showShort("别闹，您怎么给自己打电话呢？");
                        return;
                    }
                }
                common.phoneDialog(this);
                break;
            //收藏  接口发送请求
            case R.id.rely_stalldeal_coll:
                if (!AppConfig.getInstance().getBoolean("isLogin", false)) {
                    startActivity(new Intent(StallDealDetailActivity.this, VerificaActivity.class));
                    return;
                } else {
                    if (!AppConfig.getInstance().getBoolean("isLogin", false)) {
                        startActivity(new Intent(this, VerificaActivity.class));
                        return;
                    }
                    common.startShakeByPropertyAnim(rely_stalldeal_anim, 0.9f, 1.2f, 11f, 500);
                    if (IsFavorite == 0) {
                        setCollege(stallId, "FavoriteSpace");
                    } else {
                        setCollege(stallId, "CancelFavoriteSpace");
                    }
                }
                break;
            case R.id.image_datum:
                if (!AppConfig.getInstance().getBoolean("isLogin", false)) {
                    startActivity(new Intent(StallDealDetailActivity.this, VerificaActivity.class));
                    return;
                } else {
                    if (spaceowertype.equals("0")) {
                        if (db != null) {
                            startActivity(new Intent(this, PersonageMaterialActivity.class)
                                    .putExtra("auth_bean", db.getUserModel())
                                    .putExtra("user_id", db.getUserId()));
                        }
                    } else if (spaceowertype.equals("1")) {
                        if (developModel != null) {
                            Intent intent = new Intent(StallDealDetailActivity.this, DevelopersMaterialActivity.class);
                            intent.putExtra("developId", developModel.getId() + "");
                            startActivity(intent);
                        }
                    }
                }
                break;
            //我要买
            case R.id.rely_stalldeal_buy:
                if (!AppConfig.getInstance().getBoolean("isLogin", false)) {
                    startActivity(new Intent(StallDealDetailActivity.this, VerificaActivity.class));
                    return;
                } else {

                    //0未成交，1锁定中(未付定金)，2待成交(已付定金)，3已成交
                    if (db != null) {
                        if (AppConfig.getInstance().getString("uid", "").equals(db.getUserId() + "")) {
//                            if ()
                            ToastUtils.showShort("不能购买自己的车位哦~");
                            return;
                        }
                        if (db.getStatusInt() == 0) {
//                            if ()
                            startActivity(new Intent(StallDealDetailActivity.this, SubmitMessageActivity.class)
                                    .putExtra("spaceId", stallId + "")
                                    .putExtra("typeInt", db.getTypeInt())
                                    .putExtra("buy_from", 1));
                        } else if (db.getStatusInt() == 1) {
                            ToastUtils.showShort("该车位已被预订");

                        } else if (db.getStatusInt() == 2) {
                            ToastUtils.showShort("该车位已被预订");

                        } else if (db.getStatusInt() == 3) {
                            ToastUtils.showShort("该车位已售出");

                        }
                    }
                }
                break;

            case R.id.rely_subscribe://约看车位

                if (!AppConfig.getInstance().getBoolean("isLogin", false)) {
                    startActivity(new Intent(StallDealDetailActivity.this, VerificaActivity.class));
                    return;
                } else {
                    if (db != null) {
                        if (AppConfig.getInstance().getString("uid", "").equals(db.getUserId() + "")) {
                            ToastUtils.showShort("这是您自己的车位哦~");
                            return;
                        }
                        if (db.getStatusInt() == 1 || db.getStatusInt() == 2) {
                            ToastUtils.showShort("该车位已被预订");
                            return;
                        } else if (db.getStatusInt() == 3) {
                            ToastUtils.showShort("该车位已被成交");
                            return;
                        }
                        startActivity(new Intent(StallDealDetailActivity.this, LookStallSubActivity.class)
                                .putExtra("spaceId", stallId + "")
                                .putExtra("typeInt", db.getTypeInt())
                                .putExtra("buy_from", 1));
                    }
                }
                break;
            case R.id.stalldealdetail_back:
                finish();
                break;
            //分期详情
            case R.id.iv_blfq:
                if (!AppConfig.getInstance().getBoolean("isLogin", false)) {
                    startActivity(new Intent(StallDealDetailActivity.this, VerificaActivity.class));
                    return;
                } else {
                    if (db != null) {
                        if (AppConfig.getInstance().getString("uid", "").equals(db.getUserId() + "")) {
                            ToastUtils.showShort("自己不能分期办理自己发布的车位");
                            return;
                        }
                        if (db.getPrice().contains("面议")) {
                            ToastUtils.showShort("该车位不支持分期");
                            return;
                        }
                        if (db.getStatusInt() == 1 || db.getStatusInt() == 2) {
                            ToastUtils.showShort("该车位已被预订");
                            return;
                        } else if (db.getStatusInt() == 3) {
                            ToastUtils.showShort("该车位已售出");
                            return;
                        }
                        getStagesBankList();

                    }
                }
                break;
            case R.id.tv_fqbl_lc:
                startActivity(new Intent(this, CarWebActivity.class)
                        .putExtra(CarWebActivity.WEB_TAG, 0)
                );
                break;
            default:
                break;
        }
    }

    private void getStagesBankList() {
        try {
            mRequest = NoHttp.createStringRequest(Urls.BANK_STAGE, LrConstant.POST);
            mRequest.add("action", "BankStageList");
            mRequest.add("uid", AppConfig.getInstance().getString("uid", ""));
            mRequest.add("phonePara", Application.DEVICE_ID);
            mRequest.add("parkingId", db.getParkingId());
            // 添加到请求队列+
            CallServer.getRequestInstance().add(this, mRequest,
                    new CustomHttpListener<StagesBankBean>(this, true, StagesBankBean.class) {
                        @Override
                        public void doWork(StagesBankBean data, String code) {
                            if (TextUtils.equals("1", code)) {
                                if (data.getData() != null && data.getData().size() > 0) {
                                    int priceZong = 0;
                                    try {
                                        String price = db.getPrice().substring(0, db.getPrice().length() - 1).trim();
                                        priceZong = Integer.parseInt(price);
                                    } catch (Exception e) {
                                        priceZong = 0;
                                    }
                                    startActivity(new Intent(StallDealDetailActivity.this, ByStagesDetailsActivity.class)
                                            .putExtra("enter_stages_from", 1)
                                            .putExtra("park_id", db.getParkingId())
                                            .putExtra("zong", priceZong)
                                            .putExtra("spaceId", stallId + "")
                                    );

                                } else {
                                    ToastUtils.showLong("此车位暂时不支持分期购买");
                                }
                            } else {
                                ToastUtils.showShort(data.getMsg() + "");
                            }
                        }

                        @Override
                        public void onFinally(JSONObject obj, String code, boolean isSucceed) {

                        }
                    }, false);
        } catch (Exception e) {
        }
    }

    //收藏的接口
    private void setCollege(int id, String FavoriteSpace) {
        try {
            mRequest = NoHttp.createStringRequest(Urls.SPACE_IP, LrConstant.POST);
            /**
             * IsFavorite: 0是未收藏  1是已收藏
             * action: FavoriteSpace是从藏接口  CancelFavoriteSpace是取消收藏接口
             * id : 车位的id
             * FavoriteSpace : 是不是已经收藏
             */
            mRequest.add("action", FavoriteSpace);
            mRequest.add("phonePara", Application.DEVICE_ID);
            mRequest.add("uid", AppConfig.getInstance().getString("uid", ""));
            mRequest.add("id", id);

            CallServer.getRequestInstance().add(baseContext, mRequest,
                    new CustomHttpListener<BaseArrayBean>(baseContext, true, BaseArrayBean.class) {
                        @Override
                        public void doWork(BaseArrayBean data, String code) {
                            if ("1".equals(code)) {
                                if (IsFavorite == 0) {
                                    ToastUtils.showShort("收藏成功");
                                    checkBox_college.setChecked(true);
                                    IsFavorite = 1;
                                } else {
                                    ToastUtils.showShort("已取消收藏");
                                    checkBox_college.setChecked(false);
                                    IsFavorite = 0;
                                }
                            }
                        }

                        @Override
                        public void onFinally(JSONObject obj, String code, boolean isSucceed) {
                            try {
                                super.onFinally(obj, code, isSucceed);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }
                    }, true);
        } catch (Exception e) {
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        stall_map.onDestroy();
        if (unbinder != null) {
            unbinder.unbind();
        }

    }

    //车位详情接口
    private void setParkingdetails(String id) {
        try {
            mRequest = NoHttp.createStringRequest(Urls.IP_SHOW, LrConstant.POST);
            mRequest.add("action", "GetParkSpaceDetail");
            mRequest.add("parkSpaceId", id);
            mRequest.add("uid", AppConfig.getInstance().getString("uid", ""));
            CallServer.getRequestInstance().add(baseContext, mRequest,
                    new CustomHttpListener<StallDetailBean>(baseContext, true, StallDetailBean.class) {
                        @Override
                        public void doWork(StallDetailBean data, String code) {
                            if ("1".equals(code)) {
                                if (data.getData().size() > 0) {
                                    scroll_stalldetail.setVisibility(View.VISIBLE);
                                    rely_stalldeal_coll.setVisibility(View.VISIBLE);
                                    if (!isWaiting) {
                                        rely_bottom.setVisibility(View.VISIBLE);
                                    }

                                    no_data.setVisibility(View.GONE);
                                    StallDetailBean.DataBean mDatas = data.getData().get(0);
                                    db = data.getData().get(0);
                                    desc.setText(mDatas.getDescription() + "");
                                    //我要买
                                    if (db.getTypeInt() == 10) {
                                        rlSubmit.setVisibility(View.VISIBLE);
                                        iwant_buy.setText("我要租");
                                        rely_subscribe.setVisibility(View.GONE);
                                    } else if (db.getTypeInt() == 11) {
                                        rely_subscribe.setVisibility(View.VISIBLE);
                                        iwant_buy.setText("我要买");
                                    }
                                    tvReadCount.setText("浏览：" + mDatas.getReadTimes() + "人");
                                    tvCollectCount.setText("收藏：" + mDatas.getCollectTimes() + "人");
                                    tvNumberTop.setText("暂无信息".equals(mDatas.getNumber()) ? "" : mDatas.getNumber());
                                    photolist.clear();
                                    for (int i = 0; i < mDatas.getPhotoList().size(); i++) {
                                        photolist.add(mDatas.getPhotoList().get(i).getPhotoUrl());
                                    }
                                    imageStalldealdetail.setImages(photolist)
                                            .setDelayTime(3000)
                                            .setBannerStyle(BannerConfig.NUM_INDICATOR)
                                            .setIndicatorGravity(BannerConfig.RIGHT)
                                            .setImageLoader(new GlideImageLoader())
                                            .start();
                                    title.setText(mDatas.getTitle());
                                    spaceowertype = mDatas.getSpaceOwerType() + "";
                                    IsFavorite = mDatas.getIsFavorite();
                                    if (IsFavorite == 0) {
                                        checkBox_college.setChecked(false);
                                    } else {
                                        checkBox_college.setChecked(true);
                                    }
                                    if (mDatas.getSpaceOwerType() == 0) {
                                        rely_approvemessage.setVisibility(View.VISIBLE);
                                        stalldealdetail_type.setText("个人");
                                        lay_xk.setVisibility(View.GONE);
                                    } else if (mDatas.getSpaceOwerType() == 1) {
                                        stalldealdetail_type.setText("开发商");
                                        lay_xk.setVisibility(View.VISIBLE);
                                        rely_approvemessage.setVisibility(View.GONE);
                                    }
                                    dataList = data.getData().get(0).getDiscount();
                                    stallDealDetailAdapter = new StallDealDetailAdapter(dataList);
                                    recycler_stalldeal.setAdapter(stallDealDetailAdapter);

                                    setStall(mDatas.getLatitude(), mDatas.getLongitude());
                                    AppConfig.getInstance().putString("Latitude", mDatas.getLatitude() + "");
                                    AppConfig.getInstance().putString("Longitude", mDatas.getLongitude() + "");
                                    price.setText(mDatas.getPrice());
                                    tvStatusInt.setText(mDatas.getStatus());
                                    if (db.getPrice().contains("面议") || db.getPrice().equals("面议") || db.getTypeInt() == 10) {
                                        rely_bystages.setVisibility(View.GONE);
                                    } else {
                                        rely_bystages.setVisibility(View.VISIBLE);
                                    }
                                    if (db.getStatusInt() != 0) {
                                        rely_bystages.setVisibility(View.GONE);
                                    }
                                    area.setText(mDatas.getArea());
                                    size.setText(mDatas.getSize() + "㎡");
                                    if (db.getTypeInt() == 10) {
                                        llProperty.setVisibility(View.GONE);
                                        llBuildTime.setVisibility(View.GONE);
                                    } else {
                                        tvProperty.setText(mDatas.getIsHaveSpace());
                                        tvBuildTime.setText(mDatas.getSpaceBuildTime());
                                    }
                                    tv_equities.setText(mDatas.getDateLine());
                                    type.setText(mDatas.getType());
                                    address.setText("地址：" + mDatas.getAddress());
                                    tv_floor.setText(mDatas.getFloorNum());
                                    tv_stalltype.setText(mDatas.getSpaceTypeString());
                                    tv_plotname.setText(mDatas.getParkingName());
                                    deal_detail_stallnum.setText(mDatas.getNumber());
                                    tvPlatformNum.setText(mDatas.getCommonNumber());
                                    tv_location_advantage.setText(mDatas.getSpaceAdvan());
                                    date.setText("发布于" + CommonUtil.timeGap(db.getCreateTime()));
//                                tv_isinstalment.setText(mDatas.getDiscount().get());
                                    if (spaceowertype.equals("1")) {
                                        photolist1.clear();
                                        for (int i = 0; i < mDatas.getLocalPhoto().size(); i++) {
                                            photolist1.add(mDatas.getLocalPhoto().get(i).getPhotoUrl());
                                        }
                                        if (photolist1.size() <= 0) {
                                            lay_xk.setVisibility(View.GONE);
                                        }
                                        image_LocalPhoto.setImages(photolist1)
                                                .setDelayTime(4000)
                                                .setBannerStyle(BannerConfig.NUM_INDICATOR)
                                                .setIndicatorGravity(BannerConfig.RIGHT)
                                                .setImageLoader(new GlideImageLoader())
                                                .start();
                                    }
                                    /**
                                     * 房价走势
                                     */
                                    if (mDatas.getParkChartX().length() > 0) {
                                        lay_plotprice.setVisibility(View.VISIBLE);
                                        String[] TendChartX1 = (mDatas.getParkChartX()).split(",");
                                        String[] TendChartY1 = (mDatas.getParkChartY()).split(",");
                                        setCharLine(TendChartX1, TendChartY1, mLineChart);
                                    } else {
                                        lay_plotprice.setVisibility(View.GONE);
                                    }
                                    /**
                                     * 车位价走势
                                     */
                                    if (mDatas.getTendChartX().length() > 0) {
                                        lay_stallprice.setVisibility(View.VISIBLE);
                                        String[] TendChartX = (mDatas.getTendChartX()).split(",");
                                        String[] TendChartY = (mDatas.getTendChartY()).split(",");
                                        setCharLine1(TendChartX, TendChartY, mLineChart1);
                                    } else {
                                        lay_stallprice.setVisibility(View.GONE);
                                    }
                                    if (spaceowertype.equals("0") && db.getUserModel() == null) {
                                        image_datum.setVisibility(View.GONE);
                                    }
                                    if (db.getUserModel() != null) {
                                        StallDetailBean.DataBean.UserModelData userModelData = db.getUserModel();
                                        if ("1".equals(userModelData.getIsRealNameAuth())) {
                                            ivAuth.setImageResource(R.mipmap.details_user_true);
                                            tvAuthStatus.setText("该用户已通过实名认证");
                                            name.setText(userModelData.getName());
                                            Glide.with(StallDealDetailActivity.this)
                                                    .load(userModelData.getPhoto())
                                                    .bitmapTransform(new CropCircleTransformation(StallDealDetailActivity.this))
                                                    .error(R.mipmap.personal_head)
                                                    .into(ivHead);
                                            String date = userModelData.getCreateTime().split(" ")[0];
                                            registerDate.setText(date.split("-")[0] + "年" + date.split("-")[1] + "月" + date.split("-")[2] + "日注册");
                                            messageCount.setText("近一个月在利人停车发布过" + userModelData.getPublishCount() + "条信息");

                                        } else {
                                            image_datum.setVisibility(View.GONE);
                                        }

                                    } else if (db.getDevelopModel() != null && db.getDevelopModel().get(0) != null) {
                                        developModel = db.getDevelopModel().get(0);
                                        name.setText(developModel.getName());
                                        Glide.with(StallDealDetailActivity.this)
                                                .load(developModel.getPhoto())
                                                .bitmapTransform(new CropCircleTransformation(StallDealDetailActivity.this))
                                                .error(R.mipmap.personal_head)
                                                .into(ivHead);
                                        String date = developModel.getBeginTime().split(" ")[0];
                                        registerDate.setText(date.split("-")[0] + "年" + date.split("-")[1] + "月" + date.split("-")[2] + "日注册");
                                        messageCount.setText("近一个月在利人停车发布过" + developModel.getTotalCount() + "条信息");
                                    }
                                } else {
                                    scroll_stalldetail.setVisibility(View.GONE);
                                    rely_stalldeal_coll.setVisibility(View.GONE);
                                    rely_bottom.setVisibility(View.GONE);
                                    no_data.setVisibility(View.VISIBLE);
                                }
                            } else {
                                scroll_stalldetail.setVisibility(View.GONE);
                                rely_stalldeal_coll.setVisibility(View.GONE);
                                rely_bottom.setVisibility(View.GONE);
                                no_data.setVisibility(View.VISIBLE);
                            }
                        }

                        @Override
                        public void onFinally(JSONObject obj, String code, boolean isSucceed) {
                            try {
                                super.onFinally(obj, code, isSucceed);
                                if (!code.equals("1")) {
                                    ToastUtils.showShort(obj.getString("msg") + "");
                                    image_datum.setVisibility(View.GONE);
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                    }, false);
        } catch (Exception e) {
        }
    }

    /**
     * 折线图
     */
    private void setCharLine(String[] x, String[] y, LineChart Chart) {
        ArrayList<String> xValues = new ArrayList<>();
        for (int i = 0; i < x.length; i++) {
            xValues.add(x[i]);
        }
        //设置图表的描述
        Chart.setDescription("");
        //设置第一条折线y轴的数据
        ArrayList<Entry> yValue1 = new ArrayList<>();
        for (int j = 0; j < y.length; j++) {
            yValue1.add(new Entry(Float.valueOf(y[j]), j));
        }
        LineChartManager.initSingleLineChart(baseContext, Chart, xValues, yValue1);
    }


    /**
     * 折线图
     */
    private void setCharLine1(String[] x, String[] y, LineChart Chart) {
        ArrayList<String> xValues = new ArrayList<>();
        for (int i = 0; i < x.length; i++) {
            xValues.add(x[i]);
        }
        //设置图表的描述
        Chart.setDescription("");
        //设置第一条折线y轴的数据
        ArrayList<Entry> yValue1 = new ArrayList<>();
        for (int j = 0; j < y.length; j++) {
            yValue1.add(new Entry(Float.valueOf(y[j]), j));
        }
        LineChartManager1.initSingleLineChart(baseContext, Chart, xValues, yValue1);
    }

    /**
     * 地图
     *
     * @param Lat
     * @param Lng
     */
    private void setStall(double Lat, double Lng) {
        if (Lat == 0.0 || Lng == 0.0) {
            frameLayout.setVisibility(View.GONE);
            return;
        }
        //初始化地图
        mBaidumap = stall_map.getMap();
        //禁止滑动
        mBaidumap.getUiSettings().setScrollGesturesEnabled(false);
        mBaidumap.getUiSettings().setZoomGesturesEnabled(false);
        mBaidumap.getUiSettings().setRotateGesturesEnabled(false);
        stall_map.showScaleControl(false);
        stall_map.showZoomControls(false);
        LatLng ll = new LatLng(Lat, Lng);
        MapStatus mapStatus = new MapStatus.Builder().target(ll).zoom(18).build();
        MapStatusUpdate u = MapStatusUpdateFactory.newMapStatus(mapStatus);
        mBaidumap.animateMapStatus(u);
        mBaidumap.setOnMapClickListener(new BaiduMap.OnMapClickListener() {
            @Override
            public void onMapClick(LatLng latLng) {
                startActivity(PlotRimMapActivity.class);
            }

            @Override
            public boolean onMapPoiClick(MapPoi mapPoi) {
                return false;
            }
        });
    }
}

